package cn.autumnorange.app.snowflake.provider.rest;

import cn.autumnorange.app.common.dto.ResultDto;
import cn.autumnorange.app.common.rpc.lock.RPCIdempotentLockTarget;
import cn.autumnorange.app.snowflake.api.SnowFlakeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
public class SnowflakeRest implements SnowFlakeService {
  @Autowired SnowFlakeService snowFlakeService;

  @RPCIdempotentLockTarget()
  @Override
  public ResponseEntity<ResultDto<Long>> getGlobalId() {
    return snowFlakeService.getGlobalId();
  }

  @Override
  public ResponseEntity<ResultDto> test(HttpServletRequest request) {
    return snowFlakeService.test(request);
  }
}
